package bs.controller;

import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import bs.anno.Logger;
import bs.service.ArticalService;
import bs.util.ResponseUtil;

/**
 * 
 * ArticalController
 *
 * @author 姜治昊
 * @time 2017年11月24日 上午10:42:16
 */
@Controller
@RequestMapping("arti")
public class ArticalController {

	@Autowired
	private ArticalService articalService;
	
	/**
	 * 获取热门文章
	 */
	@Logger(description="获取热门文章")
	@RequestMapping(value="hotartis", method=RequestMethod.GET)
	public void getHotArticals(HttpServletResponse response, 
			@RequestParam(required=false, defaultValue="1") int page, 
			@RequestParam(required=false, defaultValue="10") int rows)  {
		net.sf.jsqlparser.expression.Expression e;
		ResponseUtil.write(response, JSONArray.fromObject(articalService.getHotArticals(page, rows)));
	}
	
}
